import { createApp } from 'vue'
import App from './App.vue'
import router from './router'

// Element Plus样式
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import 'element-plus/theme-chalk/dark/css-vars.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
// 全局样式
import '@/assets/styles/index.scss'
import {ElMessage} from "element-plus";

const app = createApp(App)

// 注册所有图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}

// 全局错误处理
app.config.errorHandler = (err, vm, info) => {
    console.error('Vue Error:', err)
    ElMessage.error('应用发生错误，请刷新页面重试')
}

app.use(ElementPlus)
app.use(router)

app.mount('#app')
